﻿@{
    ViewBag.Title = "Index";
}
<link href="~/Content/css/framework-theme.css" rel="stylesheet" />
<link href="~/Content/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/select2/select2.min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/lang/zh-CN.js"></script>
<script type="text/javascript">
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('#Contents', {
            uploadJson: '/KindEditor/SaveFiles',
            fileManagerJson: '/KindEditor/FileManager',
            allowFileManager: true,
            urlType:"domain"
        });
    });
</script>
@this.RefStyle("~/Content/webuploader/webuploader.css")
@this.RefScript("~/Content/webuploader/webuploader.js")
@Html.Partial("Index_js")
<style type="text/css">
        /*
    .img_thum {max-width:100px;}*/
</style>
<style type="text/css">
    #picker {
        display: inline-block;
        line-height: 10px;
        vertical-align: middle;
        margin: 0 12px 0 0;
    }

    .img_thum {
        width: 100px;
        margin-right: 5px;
    }

    .img_red {
        border: 1px solid #ff6a00;
    }

    #thelist {
        overflow-y: hidden;
        overflow-x: scroll;
    }
</style>
<div style="width:100%;">
    <div class="topPanel">
        <div class="toolbar">
            <a class="a-btn-refresh" onclick="$ace.reload()"></a>
            <!--<button class="a-btn-edit" data-bind="click:edit,disable:!dataTable.selectedModel()">修改</button>
            <button class="a-btn-add" data-bind="click:add">添加</button>

            <button class="a-btn-add" data-bind="click:batchAdd">数据导出</button>

    <button class="a-btn-delete" data-bind="click:del,disable:!dataTable.selectedModel()">删除</button>-->
        </div>
         
    </div>
    <div>
        <table class="table table-hover" data-bind="with:dataTable">
            <thead>
                <tr>
                    <th style="width:20px;"></th>
                    <th>标题</th>
                    <th>日志内容</th>
                    <th>执行结果</th>
                    <th>记录时间</th>
                     
                </tr>
            </thead>
            <tbody data-bind="foreach:models">
                <tr data-bind="click:$parent.selectRow">
                    <td data-bind="text:Id"></td>
                    <td data-bind="text:Title"></td>
                    <td data-bind="text:LogContent"></td>
                    <td data-bind="text:Result"></td>
                    <td data-bind="timeString:AddDate"></td>


                </tr>
            </tbody>
            @Html.Partial("_tfoot")
        </table>
    </div>
</div>

<dialogbox data-bind="with:dialog" style="width:80%;">
    <form id="form1">
        
        <!------------------------------------------------------------------------------------->
        <div class="pro_tab">
            
            <table class="form-table">
                <tbody>
                   
                  
                    <tr>
                        <td class="form-title"></td>
                        <td class="form-value">
                            
                        </td>
                        <td class="form-title"></td>
                        <td class="form-value">
                            <button class="a-btn-info" id="btn_create">生成预览</button>
                            <button class="a-btn-info" id="btn_save">保存</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <table class="form-table">
                <tbody>
                    <tr>
                        <td class="form-title">防伪码</td>
                        <td class="form-value">
                            <textarea   class="a-control"   id="codes"></textarea>
                        </td>
                    </tr>
                     
                </tbody>
            </table>
        </div>
        
    </form>
</dialogbox>

<script type="text/javascript">
    pad = function (tbl) {
        return function (num, n) {
            return (0 >= (n = n - num.toString().length)) ? num : (tbl[n] || (tbl[n] = Array(n + 1).join(0))) + num;
        }
    }([]);
    jQuery(function () {
        

        jQuery("#btn_create").click(function () {
            var PreCode = $("#PreCode").val();
            var Max = $("#Max").val();
            var Num = $("#Num").val();
            var dt = new Date();
            var Year = dt.getFullYear();
            var Month = dt.getMonth() + 1;
            var Day = dt.getDate();
            var code1 = PreCode + Year + Month + Day;
            var val = "";
            var cl = Number(Max) - code1.length;
            console.log(cl);
            for (var i = 0; i < Num; i++)
            {
                console.log(i);
                var code2 = pad(i, cl);
                console.log(code1 + code2);
                val += code1 + code2+";";
            }
            $("#codes").val(val);
            return false;
        });

        //BatchAdd
        $("#btn_save").click(function () {
            var CateID = $("#ProSortID").val();
            var Codes = $("#codes").val();
            if (CateID != "" && Codes != "") {
                $ace.post("/Wiki/CKCate/BatchAdd", { CateID: CateID, Codes: Codes }, function (result)
                {
                    if (result.Status == 100) {
                        $ace.msg(result.Msg);
                    }
                    else {
                        $ace.msg(result.Msg);
                    }
                    
                });
            }
            return false;
        });

    });
    
</script>
